package com.gxa.mobile.controller;

import com.gxa.Dto.GoodsRpcDto;
import com.gxa.core.result.Result;
import com.gxa.core.result.ResultUtils;
import com.gxa.mobile.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lch
 * @date 2024/3/22 11:21
 * @description 商品列表和商品详情
 **/
@RestController
public class GoodsController {


    @Autowired
    private GoodsService goodsService;
    /**
     * 根据id查询商品详情
     * @param goodsId
     * @return
     */
    @GetMapping("/Goods/showGoodById")
    public Result showGoodsById(String goodsId) {

        return ResultUtils.buildSuccess(this.goodsService.findGoodsById(goodsId));
    }


    /**
     * 查询所有商品
     * @return
     */
    @GetMapping("/Goods/showGoodsView")
    public Result showGoodsList() {

        return ResultUtils.buildSuccess(this.goodsService.findAllGoods());
    }

    /**
     * 删除商品redis缓存
     * @param goodsId
     * @return
     */
    @GetMapping("/Goods/deleteGoodsCache")
    public Result deleteGoodsCache(Integer goodsId){

        this.goodsService.deleteGoodsCache(goodsId);

        //默认删除成功
        return ResultUtils.buildSuccess();
    }


}
